package org.noote.libs.widget;

public class Widget_VRotationPad extends Widget_Window {

	protected boolean _bRightPressed = false;
	protected boolean _bLeftPressed = false;

	public Widget_VRotationPad(Widget_Window parent) {
		super(parent);
	}
	
	public Widget_VRotationPad(Widget_Window parent, WidgetTheme theme) {
		super(parent, theme);
	}
	
	@Override
	public void create()
	{
		super.create();
		
		setWorkSpace(0, 0, _theme.padSizeX, _theme.padSizeY);
		setBackground(_theme._textures.getTextureID(WidgetTheme.TEXTID_VROT));
		setBackgroundColor(_theme.colorLightGray);
	}

	@Override
	protected void _checkButtons()
	{
		super._checkButtons();
		
		_bRightPressed = false;
		_bLeftPressed = false;
		
		if(_iState == TOUCH_MOVED)
			_iState = TOUCH_PRESSED;
		
		if((_iState == TOUCH_RELEASED && _iOldState == TOUCH_PRESSED)
				|| (_iOldState == TOUCH_RELEASED && _iState == TOUCH_PRESSED))
			_bNewEvent = true;
		
		if(_iState == TOUCH_RELEASED) return;

		float fLimit = 0.5f;
		
        if(_fTouch_X>fLimit)
			_bLeftPressed = true; 
		else if(_fTouch_X<fLimit)
			_bRightPressed = true;
 
	}

	public boolean getButtonRight(){return _bRightPressed;}
	public boolean getButtonLeft(){return _bLeftPressed;}
}
